# -*- coding: utf-8 -*-
"""
@Time    : 2021/10/7 19:15
@Author  : Leibuyun
@File    : 通用装饰器.py
"""

flag = False


def login_wrapper(fn):
    def inner(*args, **kwargs):
        while True:
            if not flag:
                login()
            else:
                ret = fn(*args, **kwargs)
                return ret
    return inner


def login():
    global flag
    username = input('请输入用户名')
    password = input('请输入密码')
    if username == 'admin' and password == '123456':
        flag = True
        print('登录成功')
    else:
        print('登录失败')


@login_wrapper
def add():
    print('添加')


@login_wrapper
def upd(arg):
    print(f'修改{arg}')


add()
add()
upd('name')
upd('age')
